<?php
    //XML header
    if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
        header("Content-type: application/xhtml+xml"); } else {
        header("Content-type: text/xml");
    }
	
	error_reporting(E_ERROR);
	
    echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");

      
   //appelle le framework Joomla pour permetttre d'utiliser l'API Joomla lors du traitement AJAX
    require_once('ajaxdefines.php');
    require_once(CUSTOM_PATH_OPERATIONS.DS.'controller.php');
    require_once(CUSTOM_PATH_PANIERS.DS.'controller.php');
    
    if (isset($_POST['customaction'])) {
        $nomAction = $_POST['customaction'];
        
        switch (strtolower($nomAction)) {        
        // Création d'une opération
        case 'creeroperation':
            $reponse = OperationsController::creerOperation();
            $statut = '';
            break;
        
        case  'remplirpanier':
            $reponse = PaniersController::remplirPanier(); 
            $statut = '';
            break;
        
        case 'finaliseroperation':
            $reponse = OperationsController::finaliserOperation();
            $statut = '';
            break;

        }        
    }
    echo "<reponse>\n";
    echo "  <statut>\n";
    echo "  ".$statut."\n";
    echo "  </statut>\n";
    echo "  <message>\n";
    echo "  ".$reponse."\n";
    echo "  </message>\n";
    echo " </reponse>";
?>